﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Wpftest.CommonClass
{
    class Student:INotifyPropertyChanged
    {
        private string name;
        public string Name
        {
            get { return name; }
            set { name = value;
                 if(this.PropertyChanged!=null)
                {
                    this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Name"));
                }
            }
        }

        private string sex;
        public string Sex
        {
            get { return sex; }
            set { sex = value;
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Sex"));
            }
            }
        }

        private int age;
        public int Age
        {
            get { return age; }
            set { age = value;
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Age"));//第一个参数为当前实例化对象，第二个参数为响应函数中的参数
            }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}
